/************************************************************
 * Project Name         [Thinking_In_Java]
 * File Name            [HelpMenuListener.java]
 * Creation Date        [11-Jul-2014]
 * 
 * Copyright© ge.y.yang@gmail.com All Rights Reserved
 * 
 * Work hard, play harder, think big and keep fit
 ************************************************************/
package pkg_02_gui.notepad_V1.ui.help;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;

/**
 * 
 * @author 不落的太阳(Sean Yang)
 * @version 1.0
 * @since JDK 6
 * 
 */
public class HelpMenuListener extends HelpMenu implements ActionListener {

	private static final long serialVersionUID = -5943886374285192547L;

	private void addListenerToItem() {
		getHelpTopicItem().addActionListener(this);
		getAboutItem().addActionListener(this);
	}

	public HelpMenuListener(String menuName) {
		super(menuName);
		addListenerToItem();
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		/** **************************帮助主题*************************** */
		if (e.getSource() == getHelpTopicItem()) {
			helpTopicPopup();
		}
		/** **************************关于主题*************************** */
		if (e.getSource() == getAboutItem()) {
			aboutPopup();
		}

	}

	/**
	 * 帮助主题
	 */
	private void helpTopicPopup() {
		Icon helpIcon = new ImageIcon(
				"src_03_best_practices/pkg_02_gui//notepad_V1/icons/logo.gif");
		String helpMessage = "感谢您使用记事本\n" + "Email:sean.yang1984@gmail.com\n"
				+ "不落的太阳";
		JOptionPane.showConfirmDialog(null, helpMessage, "帮助",
				JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE,
				helpIcon);
	}

	/**
	 * 关于记事本
	 */
	private void aboutPopup() {
		Icon aboutIcon = new ImageIcon(
				"src_03_best_practices/pkg_02_gui//notepad_V1/icons/logo.gif");
		String aboutMessage = "Version1.0\n"
				+ "Email:sean.yang1984@gmail.com\n" + "不落的太阳";
		JOptionPane.showConfirmDialog(null, aboutMessage, "关于",
				JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE,
				aboutIcon);
	}
}
